function [ fout ] = lpf_fft( fin, fsin, fcut )

if (fsin <= fcut)
    error('fsin <= fcut');
end
if (mod(size(fin, 2), 2) ~= 0)
    error('fftshift and ifftshift will fail');
end

ffout = fftshift(fft(fin)); 
m = (size(ffout, 2) + 1) / 2;
d = size(ffout, 2) / fsin * fcut;
x1 = round(m - d);
x2 = x1 + (m - x1)*2;
ffout(1:1:x1) = 0;
ffout(x2:1:end) = 0;
fout = real(ifft(fftshift(ffout)));

end

